package org.hive.sequence.plugin
{
	import flash.display.DisplayObject;
	
	import gs.TweenLite;
	
	import org.hive.Hive;
	import org.hive.managers.plugin.LayoutManager;
	import org.hive.sequence.Sequence;
	
	public class TweenLiteAction
	{
		public static function init(hive:Hive):void
		{	
			if(Hive.DEBUG_MODE){trace( "TweenLiteAction :: init" )}
			
			//_____________ Register Object :: DisplayObject : TweenLite
			function tweenableDisplayObjectFunc( action:*, sequence:Sequence, positionInSequence:int ):void {
				var scope:DisplayObject = action.scope as DisplayObject;
				var time:Number = action.time;
				delete action.scope;
				delete action.time;
				
				var lm:LayoutManager = hive.getManager(LayoutManager.key) as LayoutManager;
				if( !lm.contains( scope ) ) lm.addChild( scope );
				TweenLite.to(scope, time, action);
			}
			hive.sequenceManager.registerAction(DisplayObject, tweenableDisplayObjectFunc, true);
		}

	}
}